package com.cxl.mapreduce._2serialize_flowsum;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author joyson
 * @create 2019-06-07-下午12:44
 */
public class FlowCountMapper  extends Mapper<LongWritable, Text, Text, FlowBean> {
    Text k=new Text();
    FlowBean v=new FlowBean();
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line=value.toString();
        String[] split = line.split("\t");
        String phone=split[1];
        long upFlow = Long.valueOf(split[split.length-3]);
        long downFlow=Long.valueOf(split[split.length-2]);
        v.set(upFlow,downFlow);
        k.set(phone);
        context.write(k,v);
    }
}
